<?php
/**
 * aheadWorks Co.
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the EULA
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://ecommerce.aheadworks.com/LICENSE-M1.txt
 *
 * @category   AW
 * @package    AW_Mobile
 * @copyright  Copyright (c) 2010-2011 aheadWorks Co. (http://www.aheadworks.com)
 * @license    http://ecommerce.aheadworks.com/LICENSE-M1.txt
 */
?>
<?php
/**
 * Temlate for Mage_Customer_Block_Address_Book block
 * @var $test Mage_Customer_Block_Address_Book
 */
?>
<div class="account-box">
        <div class="primary-address-list">
            <div class="page-head"><h3><?php echo $this->__('Default Addresses') ?></h3></div>
            <div class="content">
            <ol>
            <?php if($_pAddsses = Mage::getSingleton('customer/session')->getCustomer()->getDefaultBilling()): ?>
                <li>
                    <h5><?php echo $this->__('Default Billing Address') ?></h5>
                    <address>
                        <?php echo $this->getAddressHtml(Mage::getSingleton('customer/session')->getCustomer()->getAddressById($_pAddsses)) ?><br/>
                        <strong><a style="display:block;margin:5px 0;" href="<?php echo $this->getAddressEditUrl(Mage::getSingleton('customer/session')->getCustomer()->getAddressById($_pAddsses)) ?>"><?php echo $this->__('Change Billing Address') ?></a></strong>
                    </address>
                </li>
            <?php else: ?>
                <li>
                    <h5><?php echo $this->__('Default Billing Address') ?></h5>
                    <?php echo $this->__('You have no default billing address in your address book.') ?>
                </li>
            <?php endif ?>

            <?php if($_pAddsses = Mage::getSingleton('customer/session')->getCustomer()->getDefaultShipping()): ?>
                <li>
                    <h5><?php echo $this->__('Default Shipping Address') ?></h5>
                    <address>
                        <?php echo $this->getAddressHtml(Mage::getSingleton('customer/session')->getCustomer()->getAddressById($_pAddsses)) ?><br/>
                        <strong><a style="display:block;margin:5px 0;" href="<?php echo $this->getAddressEditUrl(Mage::getSingleton('customer/session')->getCustomer()->getAddressById($_pAddsses)) ?>"><?php echo $this->__('Change Shipping Address') ?></a></strong>
                    </address>
                </li>
            <?php else: ?>
                <li>
                    <h5><?php echo $this->__('Default Shipping Address') ?></h5><?php echo $this->__('You have no default shipping address in your address book.') ?>
                </li>
            <?php endif ?>
            </ol>
        </div>
        </div>
        <div class="address-list">
            <div class="page-head"><h3><?php echo $this->__('Additional Address Entries') ?></h3></div>
            <div class="content">
            <ol>
            <?php if($_pAddsses = $this->getAdditionalAddresses()): ?>
                <?php foreach($_pAddsses as $_address): ?>
                <li>
                    <address>
                        <?php echo $this->getAddressHtml($_address) ?><br/>
                        <strong><a href="<?php echo $this->getUrl('customer/address/edit', array('id'=>$_address->getId())) ?>"><?php echo $this->__('Edit Address') ?></a></strong>
                        <span class="pipe">|</span>
                        <strong><a href="#" onclick="return deleteAddress('<?php echo $_address->getId() ?>');" class="link-remove"><?php echo $this->__('Delete Address') ?></a></strong>
                    </address>
                </li>
                <?php endforeach; ?>
            <?php else: ?>
                <li><strong><?php echo $this->__('You have no additional address entries in your address book.') ?></strong><br /><br /></li>
            <?php endif ?>
            </ol>
            </div>
        </div>
     <div class="a-center">
         <a class="button grey left"  title="Go back" href="<?php echo Mage::getUrl('customer/account');?>"><span class="nowrap"><?php echo $this->__('Back');?></span></a>&nbsp;&nbsp;&nbsp;
         <button type="button" class="form-button" onclick="window.location='<?php echo $this->getAddAddressUrl() ?>';"><span><?php echo $this->__('Add New Address') ?></span></button>
     </div>
</div>
<script type="text/javascript">
    function deleteAddress(addressId) {
        if(confirm('<?php echo $this->__('Are you sure you want to delete this address?') ?>')) {
            window.location='<?php echo $this->getDeleteUrl() ?>id/'+addressId;
        }
        return false;
    }
</script>
